package com.uns1066.unsbar.util;

import java.io.IOException;
import java.util.List;

public class CaptureImageUtil {
	/**
	 * 
	 * @param fileFolder : 源文件完整路径
	 * @param imgPath：生成图片的完整路径
	 * @param width：宽
	 * @param height： 高
	 * @param FFMPEG_PATH
	 * @return
	 * @throws IOException
	 */
	public static synchronized boolean processImg(String fileFolder,String newImgPath, int width, int height) throws Exception {
		List<String> commands = new java.util.ArrayList<String>();
		commands.add("ffmpeg");
		commands.add("-y");
		commands.add("-i");
		commands.add(fileFolder);
		commands.add("-ss 1");
		commands.add("-vframes");
		commands.add("1");
		commands.add("-r");
		commands.add("1");
		commands.add("-ac");
		commands.add("1");
		commands.add("-ab");
		commands.add("2");
		commands.add("-s");
		commands.add(Integer.toString(width) + "*" + Integer.toString(height));
		commands.add("-f");
		commands.add("image2");
		commands.add(newImgPath);
		ProcessBuilder builder = new ProcessBuilder();
		builder.command(commands);
		builder.start();
		return true;

	}
}
